<template>
  <div id="app" class="wrapper" style="padding-top: 10px;">
    <div class="p-content">
      <div class="m-post">
        <form id="travelForm">
          <div class="post-tab clearfix">
            <input type="hidden" name="orderType" id="orderType" value="1" />
            <div :class="['tab-item', typeList ? 'on' : null]">
              <a
                href="javascript:;"
                class="orderBy"
                style="margin-right: 20px;"
                @click="getData(1)"
              >
                最新游记
              </a>
            </div>
            <div :class="['tab-item', typeList ? null : 'on']">
              <a
                href="javascript:;"
                class="orderBy"
                @click="getData(2, perExpendType, dayType, false)"
              >
                最热游记
              </a>
            </div>
          </div>
          <div class="navbar-sub clearfix">
            人均花费：
            <select
              name="perExpendType"
              class="com-opt"
              v-model="perExpendType"
            >
              <option value="-1">不限</option>
              <option value="1">1-999</option>
              <option value="2">1K-6K</option>
              <option value="3">6K-20K</option>
              <option value="4">20K以上</option>
            </select>

            出行天数：
            <select name="dayType" class="com-opt" v-model="dayType">
              <option value="-1">不限</option>
              <option value="1">3天以下</option>
              <option value="2">4-7天</option>
              <option value="3">8-14天</option>
              <option value="4">15天以上</option>
            </select>
            <div class="tn-write">
              <a href="javascript:void(0);" class="btn-add">
                <i></i>
                写游记
              </a>
            </div>
          </div>
        </form>
        <div class="_notelist">
          <div class="post-list">
            <ul>
              <li
                class="post-item clearfix"
                v-for="item in dataList"
                :key="item.id"
                @click="$router.push(`travelDetail?id=${item.id}`)"
              >
                <div class="post-cover">
                  <a href="javascript:void(0)">
                    <img
                      width="215"
                      height="135"
                      :src="item.coverUrl"
                      class="lazy"
                      style="display: inline;"
                    />
                  </a>
                </div>
                <div class="post-ding">
                  <span id="topvote11710590">{{ item.thumbsupnum }}</span>
                  <a
                    href="javascript:;"
                    data-japp="articleding"
                    data-iid="11710590"
                    data-vote="2067"
                    class="btn-ding"
                  >
                    顶
                  </a>
                </div>
                <h2 class="post-title yahei hasxjicon">
                  <a href="javascript:void(0)" class="title-link">
                    {{ item.title }}
                  </a>
                </h2>
                <div class="post-author">
                  <span class="author">
                    <a href="javascript:;" rel="nofollow">
                      <img
                        src="../../public/img/default.jpg"
                        width="15px"
                        class="lazy"
                        style="display: inline;"
                      />
                    </a>

                    作者：
                    <a href="javascript:;" rel="nofollow">
                      {{ item.author.nickname }}
                    </a>
                  </span>
                </div>
                <div class="post-content">
                  {{ item.summary }}
                </div>
                <span class="status">
                  <i class="icon_view"></i>
                  {{ item.viewnum }}
                  <i class="icon_comment"></i>
                  {{ item.replynum }}
                </span>
              </li>
            </ul>
          </div>
          <div style="float: right;">
            <div style="float: left;">
              <span style="line-height: 30px;">
                共2页 / 16条&nbsp;&nbsp;&nbsp;
              </span>
            </div>
            <div id="pagination" class="jq-pagination" style="display: inline;">
              <a
                class="prev disabled"
                href="javascript:void(0);"
                jp-role="prev"
                jp-data="0"
              >
                上一页
              </a>
              <a
                href="javascript:void(0);"
                jp-role="page"
                jp-data="1"
                class="active"
              >
                1
              </a>
              <a href="javascript:void(0);" jp-role="page" jp-data="2">2</a>
              <a
                class="next"
                href="javascript:void(0);"
                jp-role="next"
                jp-data="2"
              >
                下一页
              </a>
              <a
                class="last"
                href="javascript:void(0);"
                jp-role="last"
                jp-data="2"
              >
                尾页
              </a>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="p-aside">
      <div class="p-top1 clearfix">
        <div class="hd">
          <h2>
            <i></i>
            旅游攻略
          </h2>
        </div>
        <ol>
          <li class="top3">
            <em class="rank-num">1</em>
            <strong><a href="javascript:;" target="_blank">北海道</a></strong>
            <a href="javascript:;" target="_blank">在皑皑白雪中泡温泉</a>
          </li>
          <li class="top3">
            <em class="rank-num">2</em>
            <strong><a href="javascript:;" target="_blank">北海道</a></strong>
            <a href="javascript:;" target="_blank">在皑皑白雪中泡温泉</a>
          </li>
          <li class="top3">
            <em class="rank-num">3</em>
            <strong><a href="javascript:;" target="_blank">北海道</a></strong>
            <a href="javascript:;" target="_blank">在皑皑白雪中泡温泉</a>
          </li>
          <li>
            <em class="rank-num">4</em>
            <strong><a href="javascript:;" target="_blank">北海道</a></strong>
            <a href="javascript:;" target="_blank">在皑皑白雪中泡温泉</a>
          </li>
          <li>
            <em class="rank-num">5</em>
            <strong><a href="javascript:;" target="_blank">北海道</a></strong>
            <a href="javascript:;" target="_blank">在皑皑白雪中泡温泉</a>
          </li>
        </ol>
      </div>
      <div class="m-box m-comm">
        <div class="hd">
          <h2>
            <i></i>
            最新游记动态
          </h2>
        </div>
        <div class="bd">
          <ul
            id="_j_new_action_list"
            style="height: auto; overflow: hidden;"
          ></ul>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { ApiTravelsQuery } from '@/utils/api'
export default {
  data() {
    return {
      // 列表数据
      dataList: [],

      //  最新与最热
      typeList: true,

      // 人均消费
      perExpendType: -1,

      // 出行天数
      dayType: -1,
    }
  },

  created() {
    this.getData()
  },

  watch: {
    perExpendType: {
      handler(newVal, oldVal) {
        console.log(newVal, oldVal)
        this.getData(1)
      },
    },
    dayType: {
      handler(newVal, oldVal) {
        this.getData(1)
        console.log(newVal, oldVal)
      },
    },
  },

  methods: {
    async getData(
      orderType = null,
      perExpendType = this.perExpendType,
      dayType = this.dayType,
      typeList = true,
      currentPage = null,
    ) {
      this.typeList = typeList
      let res = await ApiTravelsQuery({
        orderType,
        currentPage,
        perExpendType,
        dayType,
      })
      console.log(res.data.data.content)
      if (res.data.code !== 200) return alert('接口请求失败')

      this.dataList = res.data.data.content
    },
  },
}
</script>

<style scoped>
@import '../css/travelnotes.css';
/* @import '../css/jqPagination.css'; */
</style>
